﻿-- Define the relationship between ActivityRoleAccess and SecurityRole
ALTER TABLE [dbo].[ActivityRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_ActivityRoleAccess_SecurityRole] FOREIGN KEY([SecurityRole])
REFERENCES [dbo].[SecurityRole] ([RoleId])
ON DELETE NO ACTION
GO
-- Define the relationship between ActivityRoleAccess and Activity
ALTER TABLE [dbo].[ActivityRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_ActivityRoleAccess_Activity] FOREIGN KEY([Activity])
REFERENCES [dbo].[Activity] ([ActivityId])
ON DELETE NO ACTION
GO
-- Define the relationship between ActivityRoleAccess and Person
ALTER TABLE [dbo].[ActivityRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_ActivityRoleAccess_CreatedByPerson] FOREIGN KEY([CreatedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between ActivityRoleAccess and Person
ALTER TABLE [dbo].[ActivityRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_ActivityRoleAccess_LastChangedBy] FOREIGN KEY([LastChangedBy])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO
-- Define the relationship between ActivityRoleAccess and Person
ALTER TABLE [dbo].[ActivityRoleAccess] WITH CHECK ADD  
       CONSTRAINT [FK_ActivityRoleAccess_Person] FOREIGN KEY([Person])
REFERENCES [dbo].[Person] ([PersonId])
ON DELETE NO ACTION
GO